package com.ybkj.daijia.server.service;

import com.ybkj.daijia.common.Result;
import com.ybkj.daijia.page.Page;
import com.ybkj.daijia.server.mc.Passenger;
import com.ybkj.daijia.server.model.Driver;
import com.ybkj.daijia.server.model.Order;
import com.ybkj.daijia.server.model.OrderStatus;
import com.ybkj.daijia.server.model.WeixinManager;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author Shine
 */
public interface OrderService {

    public List<Order> findAllFinished(Integer page, Integer limit);

    public Long countAllFinished();

    /**
     * 执行中 status 0 , 1 , 2
     *
     * @param param
     */
    public Page<Order> queryAll(String param);

    /**
     * 已销单 status 5
     */
    public Page<Order> queryCancel(String param);

    /**
     * 异常订单 订单里程为小于1公里的、行驶时间小于2分钟的，实收金额和应收金额不符的
     */
    public Page<Order> queryWarm(String param);

    /**
     * 已结算 status 3
     *
     * @param payType
     */
    public Page<Order> queryFinish(String param, String payType);

    /**
     * 已报单 status 6
     *
     * @param payType
     */
    public Page<Order> queryBaodan(String param, String payType);

    /**
     * @param order
     * @return
     */
    public Order update(Order order);

    /**
     * @param id
     * @return
     */
    public Order findOne(Long id);

    /**
     * 根据一组ID查询出管理员信息
     *
     * @param ids
     * @return
     */
    public List<Order> findByIdIn(Long[] ids);

    /**
     * 删除
     *
     * @param order
     */
    public void delete(Order order);

    public List<Order> createAndPaidan(Order order, Integer driverNum, Long[] couponIds,
        Double longitude,
        Double latitude, Long[] check_drivers, Long companyId, Long weixinManagerId,
        BigDecimal fixPriceMoney, BigDecimal yuguMoney);

    public Result<Order> create(Order order, Integer driverNum, Long[] couponIds, Double longitude,
        Double latitude, Long companyId, Long weixinManagerId, BigDecimal fixPriceMoney,
        BigDecimal yuguMoney);

    /**
     * 派单
     *
     * @param driver
     * @param order
     */
    public void paidan(Driver driver, Order order);

    public int autoPaidan(Driver driver, Order order);

    /**
     * 调度订单
     *
     * @param limit
     */
    public List<Order> listNewOrders(Integer limit);

    /**
     * 销单
     *
     * @param order
     * @param content
     */
    public void cancel(Order order, String content);

    /**
     * 强制销单
     *
     * @param order
     * @param content
     */
    public void powercancel(Order order, String content);

    /**
     * 客户销单
     *
     * @param order
     * @param content
     */
    public void customerCancel(Order order, String content);

    /**
     * 客户经理销单
     *
     * @param order
     * @param content
     */
    public void managerCancel(Order order, String content);

    /**
     * 收回
     *
     * @param order
     * @param content
     */
    public void revoke(Order order, String content);

    /**
     * 强制收回
     *
     * @param order
     * @param content
     */
    public void powerrevoke(Order order, String content);

    /**
     * 申请销单
     *
     * @param order
     * @param content
     */
    public void refuse(Order order, String content);

    /**
     * 司机接受工单
     *
     * @param order
     */
    public int accept(Order order, Driver driver);


    /**
     * 根据司机和完成时间查询订单信息
     *
     * @param driverID
     * @param begin
     * @param end
     * @return
     */
    public List<Order> findByDriverAndFinishTime(Long driverID, Date begin,
        Date end);

    /**
     * 根据司机与时间统计订单总数
     *
     * @param driverID
     * @param begin
     * @param end
     * @return
     */
    public long counByDriverAndFinishTime(Long driverID, Date begin, Date end);

    /**
     * 根据司机与时间统计订单收入
     *
     * @param driverID
     * @param begin
     * @param end
     * @return
     */
    public double sumByDriverAndFinishTime(Long driverID, Date begin, Date end);

    /**
     * 根据司机和完成时间分页查询订单信息
     *
     * @param driverID
     * @param begin
     * @param end
     * @return
     */
    public Page<Order> findByDriverAndFinishTime(Long driverID, Date begin, Date end, Integer page,
        Integer limit);

    /**
     * 根据司机统计订单总数
     *
     * @param driverID
     * @return
     */
    public long counByDriver(Long driverID);

    /**
     * 根据司机统计订单总金额
     *
     * @param driverID
     * @return
     */
    public double sumByDriver(Long driverID);

    /**
     * 根据司机查询订单信息
     *
     * @param driverID
     * @param page
     * @param limit
     * @return
     */
    public Page<Order> findByDriver(Long driverID, Integer page, Integer limit);

    /**
     * 完成订单
     *
     * @param order
     * @param date
     * @param date2
     * @param couponId
     * @return
     */
    public Order completeTaskV3(Order order, Date date, Date date2, Long couponId);

    /**
     * 根据司机状态查询订单信息
     *
     * @param status
     * @param begin
     * @param end
     * @return
     */
    public long counByStatusAndFinishTime(Integer status, Date begin, Date end);

    /**
     * 根据司机和订单状态查询订单信息
     *
     * @param driver
     * @param orderStatus
     * @return
     */
    public List<Order> findByDriverAndStatus(Driver driver, Integer orderStatus);

    /**
     * 报单
     *
     * @param driver
     * @param xml
     * @return
     */
    public boolean report(Driver driver, String xml);

    public boolean reportV3(Order order, String xml);

    public Result<Order> confirmTaskV4(Order order, Driver driver);

    /**
     * 补单
     *
     * @return
     */
    public Result<Order> fillOrderV2(Order order, Long driverID);

    public Result<Order> fillOrderV4(Order order, Long driverID);

    public List<Order> orderAppointment(Order order, Integer driverNum, Double longitude,
        Double latitude, String acKey);

    public Page<Map<String, Object>> historyOrderV3(String phone, String acKey, Integer page,
        Integer limit);

    public Page<Order> todayOrder(String phone, String acKey, Integer page, Integer limit);

    public List<Order> todayOrder(String phone);

    public long countByStatus(int orderStatusNew);

    public long countByStatus(int orderStatusYipaidan, int orderStatusBusy);

    public long countFinishedByFinishTime(Date begin, Date end);

    public long countFinishedByPassengerAndFinishTime(Long passengerId, String[] orderFromSources,
        Date begin, Date end);

    public BigDecimal sumFinishedMoneyByFinishTime(Date begin, Date end);

    public void customerOrder(Order order, Driver driver, Passenger passenger, String acKey);

    public List<Order> findTodayOrderByMember(Date begin, Date end, Long memberid);

    public List<Order> listBusyOrders();

    public void arrivePlace(Order order, Date arriveTime);

    public void startDrive(Order order, Date arriveTime, Date startDriveTime, Driver driver,
        String isWannaWc, Long workCarTime, Long areaId);

    public List<Order> listByStatus(Integer status);

    public List<Order> listByStatus(Integer status1, Integer status2);

    public List<Order> listByDriverAndStatus(Long id, Integer orderStatusBusy);

    public Result<Order> modifyCash(Order order, BigDecimal couponMoney, BigDecimal cashMoney,
        BigDecimal signMoney, BigDecimal balanceMoney, BigDecimal alipayMoney,
        BigDecimal weixinMoney, BigDecimal driverMoney, BigDecimal memberMoney, BigDecimal wxMoney,
        String content);

    public Result<Order> updateInfo(Order order, String fromPlace, String clientPhone,
        String userPhone, String clientName);

//    public Result<Order> getTuijianMoney(Order order, BigDecimal cash);

    public Result<Order> weixinOrder(Order order, Driver driver, Passenger passenger);

    public List<Order> managerBook(WeixinManager weixinManager, Order order, Integer driverNum);

    public List<Order> managerBookV2(WeixinManager weixinManager, Order order, List<String> phones);

    public Order memberBook(Order order, String wxuser);

    public List<Order> rushOrder(Double longitude, Double latitude, Driver driver);

    public void getRushOrder(Driver driver, Order order);

    public Order webOrder(Order order);

    public List<Order> listWorkingOrdersByDriver(Long id);

    public void yupaidan(Driver driver, Order order, String type);

    public void zhuandan(Order order, Driver driver, Driver oldDriver);

    public void powerZhuandan(Order order, Driver driver, Driver oldDriver);

    public void zhuandanV4(Order order, Driver driver, Driver oldDriver);

    public Page<Order> pageByMembmerAndStatus(Long memberId,
        Integer orderStatusNew, Integer page, Integer limit);

    public Page<Order> pageByMembmerAndStatus(Long memberId,
        Integer status1, Integer status2, Integer page,
        Integer limit);

    public Page<Order> pageByMembmerAndStatus(Long memberId,
        Integer status1, Integer status2, Integer status3, Integer page,
        Integer limit);

    public long countByMember(String phone, Date begin, Date end);

    public long countNotCancelByMember(String phone, Date begin, Date end);

    /**
     * 查询预约地附近在执行的订单
     *
     * @param orderlng
     * @param orderlat
     * @param paidanKm
     * @return
     */
    public List<Order> queryNearBy(Double orderlng, Double orderlat, Double paidanKm);

    /**
     * 根据司机和订单状态查询最后一条数据
     *
     * @param driverID
     * @param orderStatus
     * @return
     */
    public Order findOneByDiverAndStatus(Long driverID, int orderStatus);

    /**
     * 根据司机查询今天最后一条已完成的数据
     *
     * @param driverID
     * @return
     */
    public Order findOneByDiverAndFinish(Long driverID, Long lastOrderId);

    /**
     * 根据司机查询最新完成的订单
     *
     * @param driverID
     * @return
     */
    public Order findLastedFinishedByDriver(Long driverID);

    /**
     * 根据司机和订单状态统计数据
     *
     * @param driverID
     * @param orderStatus
     * @return
     */
    public long countByDriverAndStatus(Long driverID, int orderStatus, Long lastOrderId);

    public List<Order> findByStatus(Integer orderStatus);

    public void driverCancel(Order order, String content);

    public Page<OrderStatus> queryRefuse(String param);

    public long countRefused();

    public Order findOneByDriverBeforeComplete(Long driverId, Long lastOrderId);

    public Order findOneYestodayOrder();

    public List<Order> findMonthOrder(Date start, Date end);

    public List<Order> findByMemberId(Long id);

    public List<Order> findActiveByMember(Long id);

    public long countActivedOrdersByDriver(Long id);

    /**
     * 3.1.0
     *
     * @param createOrderName
     */
    public Page<Map<String, Object>> daijialistData(String orderNumber,
        String clientPhone, String driverPhone, String companyName, String createOrderName,
        String[] orderType, String[] status, boolean warm, Date start, Date end, Date startFinish,
        Date endFinish);


    public List<Order> daijialistExport(String orderNumber, String clientPhone, String driverPhone,
        String companyName, String createOrderName, String[] orderType, String[] status,
        boolean warm, Date start, Date end, Date startFinish, Date endFinish);

    public List<Order> findActivedOrdersByDriver(Long driverId);

    /**
     * 3.1.0
     *
     * @param ack
     */

    public Map<String, Object> getPrice(String ack, Long passengerId, Double startLat,
        Double startLng, Double endLat, Double endLng);

    public Map<String, Object> getNewPrice(String ack, Long passengerId, Integer time,
        Double mileage, Double startLat, Double startLng);

    //APP查询代驾订单接口
    public Map<String, Object> findByParams(Long passengerId, Integer page, Integer rows);

    /**
     * 微信V5获取客户订单信息
     *
     * @param passengerId 客户ID
     * @param page        页码
     * @param rows        条数
     * @return
     */
    public Map<String, Object> findByParamsV5(Long passengerId, Integer page, Integer rows);

    public Map<String, Object> hurryOrder(Long orderId);

    //查询催单
    public List<Order> findCuidanOrders();

    //关闭催单时间
    public int closeCuidan(Long orderId);

    //更新催单时间
    public int updateCuidan(Long orderId);

    //结算
    public Result<Order> completeTaskNewV3(Order order, Passenger passenger, Driver driver,
        String completeType, String payType, BigDecimal hasPayed, boolean adminComplete);

    //查询同单订单
    public List<Order> findByGroup(Long orderGroupId);

    //到达预约地
    public void arrivePlaceV4(Order order);

    //查询未支付订单数量
    public long countNotPayByPassenger(Long passengerId);

    //查询未完成订单数量
    public long countNotFinishedByPassenger(Long passengerId);

    //查询今天新单、销单、执行中数量
    public long countTodayOrderByPassenger(Long passengerId);

    //开始出发
    public void startDriveV4(Order order, Integer waiteTime);

    //满足金额大于lowestMoney的完成订单
    public List<Order> findReward(Long driverId, BigDecimal lowestMoney, Date start, Date end);

    public Map<String, Object> getMyPrice(Integer time, Double mileage, Driver driver, String phone,
        Long areaId);

    public Result<Order> autoCallback(Order order, Driver driver);

    public boolean IsThereAnSameOrder(String OrderNumber);


}
